/*
 * 易族智汇（北京）科技有限公司 版权所有。
 * 未经许可，您不得使用此文件。
 * 官方地址：www.javamall.com.cn
 */
package com.enation.app.javashop.core.client.feignimpl.member;

import com.enation.app.javashop.client.member.MemberClient;
import com.enation.app.javashop.core.client.fallback.member.MemberClientFallbackFactory;
import com.enation.app.javashop.core.handler.FeignConfiguration;
import com.enation.app.javashop.model.member.dos.Member;
import com.enation.app.javashop.model.member.dos.MemberCoupon;
import com.enation.app.javashop.model.member.dos.MemberPointHistory;
import com.enation.app.javashop.model.member.vo.BackendMemberVO;
import com.enation.app.javashop.model.security.ScanModuleDTO;
import com.enation.app.javashop.model.security.ScanResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 店铺接口Feign实现
 *
 * @author kingapex
 * @version 1.0
 * @since 7.0.0
 * 2018/7/6
 */
@FeignClient(name = "member-service", fallbackFactory = MemberClientFallbackFactory.class,configuration = {FeignConfiguration.class})
public interface MemberClientFeigntImpl extends MemberClient {

    @Override
    @RequestMapping(value = "/client/members/login/add-num/{member_id}", method = RequestMethod.PUT)
    void updateLoginNum(@PathVariable("member_id") Long memberId, @RequestParam("now") Long now);

    /**
     * 获取一个会员对象
     *
     * @param memberId
     * @return
     */
    @Override
    @RequestMapping(value = "/client/members/{member_id}", method = RequestMethod.GET)
    Member getModel(@PathVariable("member_id") Long memberId);

    /**
     * 登录数清零
     */
    @Override
    @RequestMapping(value = "/client/members/login/zero", method = RequestMethod.GET)
    void loginNumToZero();

    /**
     * 修改会员
     *
     * @param member 会员
     * @param id     会员主键
     * @return Member 会员
     */
    @Override
    @RequestMapping(value = "/client/members/{id}", method = RequestMethod.POST)
    Member edit(@RequestBody Member member, @PathVariable("id") Long id);

    /**
     * 会员积分操作，这个方法可同时进行添加积分和消费积分
     * 1、添加积分
     * gadePointType 为1则为添加等级积分  gadePoint为积分值
     * consumPointType 为1则为添加消费积分  consumPoint为消费积分值
     * <p>
     * 2、消费积分
     * gadePointType 为0则为消费等级积分  gadePoint为积分值
     * consumPointType 为0则为消费消费积分  consumPoint为消费积分值
     * <p>
     * 如果没有操作则gadePointType 为0 gadePointType为1
     * 如果没有操作则consumPoint 为0 consumPointType为1
     *
     * @param memberPointHistory 会员积分
     */
    @Override
    @RequestMapping(value = "/client/members/point", method = RequestMethod.POST)
    void pointOperation(@RequestBody MemberPointHistory memberPointHistory);

    /**
     * 查询所有的会员id
     *
     * @return
     */
    @Override
    @RequestMapping(value = "/client/members/all-member-ids", method = RequestMethod.GET)
    List<String> queryAllMemberIds();

    /**
     * 读取我的优惠券
     *
     * @param memberId
     * @param mcId
     * @return
     */
    @Override
    @RequestMapping(value = "/client/members/coupon/{member_id}/{mc_id}", method = RequestMethod.GET)
    MemberCoupon getModel(@PathVariable("member_id") Long memberId, @PathVariable("mc_id") Long mcId);

    /**
     * 将优惠券变为已使用
     *
     * @param mcId
     * @param orderSn
     */
    @Override
    @RequestMapping(value = "/client/members/coupon/{mc_id}/used", method = RequestMethod.POST)
    void usedCoupon(@PathVariable("mc_id") Long mcId, @RequestParam("order_sn") String orderSn);

    /**
     * 领取优惠券
     *
     * @param memberId 会员id
     * @param couponId 优惠券id
     */
    @Override
    @RequestMapping(value = "/client/members/coupon/{member_id}/{coupon_id}", method = RequestMethod.POST)
    void receiveBonus(@PathVariable("member_id") Long memberId,@RequestParam("member_name") String memberName, @PathVariable("coupon_id") Long couponId);

    /**
     * 查询新的会员
     *
     * @param length
     * @return
     */
    @Override
    @RequestMapping(value = "/client/members/new", method = RequestMethod.GET)
    List<BackendMemberVO> newMember(@RequestParam("length") Integer length);

    @Override
    @RequestMapping(value = "/client/members/scan-module", method = RequestMethod.POST)
    ScanResult scanModule(@RequestBody ScanModuleDTO scanModuleDTO);

    /**
     * 会员数据重新签名
     */
    @Override
    @RequestMapping(value = "/client/members/resign", method = RequestMethod.GET)
    void reSign();

    /**
     * 修复会员数据
     * @param memberId
     */
    @Override
    @RequestMapping(value = "/client/members/repair/{member_id}", method = RequestMethod.GET)
    void repair(@PathVariable("member_id")Long memberId);
    @Override
    @RequestMapping(value = "/client/members/sleep", method = RequestMethod.GET)
    void sleepMember(@RequestParam("time_stamp")long timeStamp);
}
